package com.jy.adscm.operation.mscyb.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.operation.mscyb.bean.JqylMaterialinfo;
import com.jy.adscm.operation.mscyb.mapper.mysql.JqylMaterialinfoMapper;
import com.jy.adscm.operation.mscyb.service.JqylMaterialinfoService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.system.mapper.mysql.JyUserMapper;
import com.jy.adscm.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2018-11-29
 */
@Service
public class JqylMaterialinfoServiceImpl extends ServiceImpl<JqylMaterialinfoMapper, JqylMaterialinfo> implements JqylMaterialinfoService {
    @Autowired
    JyUserMapper jyUserMapper;
    @Override
    public List<JqylMaterialinfo> selectByTid(String tid) {
        Wrapper<JqylMaterialinfo> wrapper =new EntityWrapper<>();
        wrapper.eq("TID",tid);
        List<JqylMaterialinfo> jqylMaterialinfos = super.selectList(wrapper);
        for (JqylMaterialinfo jqylMaterialinfo : jqylMaterialinfos) {
            if (AdscmBaseUtils.getInstance().isNotEmpty(jqylMaterialinfo.getPerson(),null)){
                JyUser jyUser = jyUserMapper.selectById(jqylMaterialinfo.getPerson());
                jqylMaterialinfo.setPersonName(jyUser.getName());
            }
        }
        return jqylMaterialinfos;
    }
}
